<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <script src="https://code.jquery.com/jquery-3.6.0.js"></script>

    <body>
        <input type="checkbox" name="" class="quanxuan" id="" />
        <br />
        <input type="checkbox" class="inputs" name="" id="" />
        <input type="checkbox" class="inputs" name="" id="" />
        <input type="checkbox" class="inputs" name="" id="" />
        <input type="checkbox" class="inputs" name="" id="" />
    </body>
    <script>
        $(".quanxuan").change(function () {
            $(".inputs").prop("checked", $(this).prop("checked"));
        });

        $(".inputs").change(function () {
            if ($(".inputs:checked").length == $("input").length - 1) {
                $(".quanxuan").prop("checked", true);
            } else {
                $(".quanxuan").prop("checked", false);
            }
        });
    </script>
</html>
